package com.ailight.smart.api.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum OperationTypeEnums {
    /**
     * 开启自动模式
     */
    ENABLE_AUTO_MODE(0, "auto_mode", ModelEnums.AUTO_MODE),

    /**
     * 开启手动模式
     */
    ENABLE_MANUAL_MODE(0, "manual_mode", ModelEnums.MANUAL_M0DE),

    /**
     * 一档
     */
    ENABLE_GEAR_ONE(1, "gear_one", ModelEnums.MANUAL_M0DE),

    /**
     * 二档
     */
    ENABLE_GEAR_TWO(2, "gear_two", ModelEnums.MANUAL_M0DE),

    /**
     * 三档
     */
    ENABLE_GEAR_THREE(3, "gear_three", ModelEnums.MANUAL_M0DE),

    /**
     * 关灯
     */
    ENABLE_LIGHT_OFF(0, "manual_off", ModelEnums.MANUAL_M0DE),
    ;

    /**
     * 操作类型--挡位
     */
    private final int gearType;
    /**
     * 操作名称
     */
    private final String opeName;

    /**
     * 对应的模式
     */
    private final ModelEnums modelEnums;

    OperationTypeEnums(int gearType, String opeName, ModelEnums modelEnums) {
        this.gearType = gearType;
        this.opeName = opeName;
        this.modelEnums = modelEnums;
    }

    public static OperationTypeEnums getOperationTypeEnums(String opeName, int gearType) {
        for (OperationTypeEnums operationTypeEnums : OperationTypeEnums.values()) {
            if (Objects.equals(operationTypeEnums.getModelEnums().getModel(), opeName) && Objects.equals(operationTypeEnums.getGearType(), gearType)) {
                return operationTypeEnums;
            }
        }
        return ENABLE_GEAR_ONE;
    }

}
